import request from "./useRequests";
import { ElMessage } from 'element-plus'
import { userinfo } from '@/stores/counter'
import getComments from '@/api/getComments'
const { comments } = getComments();
const user = userinfo()
export default function delComments() {
  
  async function deleting(commentId: string,articleId:string) {
    try {
      const res = await request.delete('/comment/'+commentId,
      {
        headers: {
          authentication: user.baseInfo.token
        },
      }
      )
      if (res.data.status) {
        ElMessage({
          showClose: true,
          message: '删除成功',
          type: 'success',
        })
        console.log(articleId)
        comments(articleId)
      }
    } catch (err: any) {
      //alert(err)
    }
  }

  return {
    deleting
  }
}